package senior.DateExer;

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Scanner;

/**
 * 6月的第3个星期日是父亲节，由用户输入年份，算出该年的父亲节是哪一天
 *
 * @author shkstart
 * @creat 2022-04-19:08
 */
public class Exer5 {
    public static void main(String[] args) {
        Calendar cal = Calendar.getInstance();
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd E");
        Scanner sc = new Scanner(System.in);
        System.out.println("输入年份：");
        int year = sc.nextInt();
        cal.set(year, 5, 1);
        for (int i = 0; i < 30; i++) {
            cal.add(Calendar.DAY_OF_YEAR, 1);
            if (cal.get(Calendar.DAY_OF_WEEK_IN_MONTH) == 3 && cal.get(Calendar.DAY_OF_WEEK) == 1) {
                System.out.println(year + "年的父亲节是：" + sdf.format(cal.getTime()));
            }
        }
    }
}
